package com.yanqu.road.server.cmd.curio;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cangbao.CurioProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.curio.CrossCurioMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CURIO_LOTTERY_UPLOAD_NOTICE, desc = "公告上传")
public class CrossCurioLotterUploadNoticeCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CurioProto.CrossCurioLotteryUploadNoticeReqMsg reqMsg = CurioProto.CrossCurioLotteryUploadNoticeReqMsg.parseFrom(packet.getBytes());
        CrossUserMgr.updateUserBaseInfo(packet.getPlayerId(), PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerMsg()));
        for (CurioProto.CurioLotteryNoticeMsg noticeMsg : reqMsg.getNoticeList()) {
            CrossCurioMgr.uploadNotice(packet.getPlayerId(), serverId, noticeMsg.getGoodsId(), noticeMsg.getType(), noticeMsg.getTime());
        }
    }

    @Override
    public void sendData() {

    }
}
